Creates an integer array of size 10. Fills it with random numbers between 1 and 100.Finds and prints the maximum, minimum, and average of all elements.
Write a program that takes a sentence as input and:
Counts the number of words. Reverses the entire sentence. Checks if it is a palindrome (ignoring spaces and case).
Design a BankAccount class with:
Private fields: accountNumber, holderName, balance.
Constructor to initialize all fields.
Methods: deposit(double amount), withdraw(double amount), and displayInfo().
Withdrawal should not allow balance to go below 0.
Create a Main class with a main method to:
Create 2 accounts. Perform deposits and withdrawals. Display final details.
Create a base class Employee with:
Fields: name, id, baseSalary.
Methods: calculateSalary() (returns baseSalary).
Create two subclasses:
Manager: adds bonus (10 percentage of baseSalary). Override calculateSalary() to add bonus.
Intern: adds stipend (fixed Rs.500). Override calculateSalary() to add stipend.
In main, create an array of Employee objects, call calculateSalary() for each, and display.
Create an abstract class Shape with an abstract method calculateArea().
Create subclasses:
Circle: field radius, area = PI * r2.
Rectangle: fields length, width, area = l * w.
Triangle: fields base, height, area = 0.5 * b * h.
Write a method printArea(Shape shape) that prints the area using polymorphism.
Create an interface Payment with methods:
void processPayment(double amount)
String getPaymentType()
Implement two classes:
CreditCardPayment: fields cardNumber, cardHolder. Override methods.
UPIPayment: fields upiId. Override methods.
In main, create an array of Payment objects, process payments, and print details.
Create a class Vehicle with:
Fields: brand, speed.
Method: move() that prints Vehicle is moving.
Create subclasses:
Car: adds doors. Override move() to print Car is driving on road.
Bike: adds hasCarrier. Override move() to print Bike is riding on road.
Write a method testDrive(Vehicle v) that calls move().
Create an interface Playable with method void play().
Implement two classes:
Song: fields title, artist. Override play() to display Playing song: title by artist.
Podcast: fields title, host. Override play() to display Playing podcast: title hosted by host.
In main, create a list of Playable objects and play all.
Design a library system with:
An interface Borrowable with methods borrow(), returnItem().
An abstract class Item with fields: id, title.
Subclasses: Book (adds author) and DVD (adds duration). Both implement Borrowable.
In main:
Create an array of Item objects (both Book and DVD).
Borrow and return items.
Print status after each operation.